﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Entities;

namespace BLL
{
    public class ChiTietGioHang:IEquatable<ChiTietGioHang>
    {
        public int SoLuong { get; set; }
        private int _idSanPham;
        public int IdSanPham
        {
            get { return _idSanPham; }
            set {
                if (
                SP == null)
                    _idSanPham = 0;
                else
                    _idSanPham = SP.IDSP;
            }
        }
        private SanPham _sanPham = null;
        public SanPham SP
        {
            get 
            {
                return _sanPham;
            }
            set { _sanPham = value; }
        }
        public string Ten { get { return SP.TenSP; } }
        public decimal Gia
        {
            get 
            {
                return SP.Gia;
            }
        }
        public decimal ThanhTien { get { return Gia * SoLuong; } }
        public ChiTietGioHang(int _idSanPham)
        {
            this.IdSanPham = _idSanPham;
        }
        public ChiTietGioHang(SanPham _sanPham) { SP = _sanPham; IdSanPham = SP.IDSP; }
        public bool Equals(ChiTietGioHang _item)
        {
            return _item.IdSanPham == this.IdSanPham;
        }
    }
}
